package com.ssy.lingxi.after.sale.controller;

import com.ssy.lingxi.after.sale.api.model.constant.AgentFlagEnum;
import com.ssy.lingxi.after.sale.api.model.vo.request.CommonIdVO;
import com.ssy.lingxi.after.sale.api.model.vo.request.ReturnSubmitVerifyVO;
import com.ssy.lingxi.after.sale.api.model.vo.request.VerifyVO;
import com.ssy.lingxi.after.sale.model.vo.request.*;
import com.ssy.lingxi.after.sale.model.vo.response.*;
import com.ssy.lingxi.after.sale.service.*;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @menu 售后能力-售后退货
 * @author 伍将
 * @date 2020/9/9
 * @version 2.0.0
 */
@RestController
@RequestMapping("/as/returnGoods")
public class ReturnGoodsController extends BaseController {

    @Resource
    private IReturnGoodsService returnService;

    @Resource
    private IReturnGoodsDetailService returnedGoodsService;

    @Resource
    private IInnerWorkflowRecordService innerWorkflowRecordService;

    @Resource
    private IOuterWorkflowRecordService outerWorkflowRecordService;

    @Resource
    private IReturnDeliveryGoodsService returnDeliveryGoodsService;

    /**
     * 售后退货申请-退货申请单查询-分页查询退货申请
     * @author 伍将
     * @date 2020/9/9
     **/
    @RequestMapping(value = "/pageByConsumer", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageByConsumer(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageByConsumer(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货申请-退货申请单查询-分页查询退货申请-im
     * @author ds
     * @date 2020/4/22
     **/
    @RequestMapping(value = "/pageByIM", method = RequestMethod.GET)
    public Wrapper<PageData<AfterSaleGoodsIMQueryVO>> pageByIM(HttpServletRequest httpRequest, @Valid AfterSaleGoodsIMPageVO request) {
        return returnService.pageByIM(getSysUser(httpRequest), request);
    }

    /**
     * 售后退货申请-查询退货申请详情
     * @author 伍将
     * @date 2020/9/9
     **/
    @RequestMapping(value = "/getDetailByConsumer", method = RequestMethod.GET)
    public Wrapper<ReturnGoodsDetailVO> getDetailByConsumer(HttpServletRequest httpRequest, Long returnId) {
        return returnService.getDetailByConsumer(getSysUser(httpRequest), returnId);
    }

    /**
     * 售后退货-退货详情-分页查询退货商品
     * @author 伍将
     * @date 2020/9/10
     **/
    @RequestMapping(value = "/pageReturnedGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsDetailQueryVO>> pageReturnGoodsDetailList(HttpServletRequest httpRequest,@Valid ReturnGoodsDetailPageVO pageVO) {
        return returnedGoodsService.pageList(getSysUser(httpRequest),pageVO);
    }

    /**
     * 售后退货申请-待提交退货申请单-分页查询退货申请
     * @author 伍将
     * @date 2020/9/10
     **/
    @RequestMapping(value = "/pageToBeSubmitByConsumer", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeSubmitByConsumer(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeSubmitByConsumer(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货申请-待提交退货申请单-提交退货申请单-新增/修改退货申请
     * @author 伍将
     * @date 2020/9/9
     **/
    @RequestMapping("/save")
    public Wrapper<Long> save(HttpServletRequest httpRequest, @RequestBody @Valid ReturnGoodsSaveVO saveVO) {
        return returnService.save(getSysUser(httpRequest), saveVO);
    }

    /**
     * 售后代客退货申请-待提交退货申请单-提交退货申请单-新增/修改退货申请
     * @author 彭冬冬
     * @date 2021/11/25
     * @param httpRequest 请求
     * @param saveVO 代客退货保存VO
     * @return 客退货申请id
     */
    @RequestMapping("/agent/save")
    public Wrapper<Long> agentSave(HttpServletRequest httpRequest, @RequestBody @Valid ReturnGoodsAgentSaveVO saveVO) {
        UserLoginCacheDTO user = buildAgentUser(httpRequest, saveVO);
        saveVO.setAgentFlag(AgentFlagEnum.YES.getCode());
        return returnService.save(user, saveVO);
    }

    /**
     * 构建代客用户
     * @author 彭冬冬
     * @date 2021/11/25
     * @param httpRequest 请求
     * @param saveVO 保存代客换货VO
     * @return 代客用户
     */
    private UserLoginCacheDTO buildAgentUser(HttpServletRequest httpRequest, ReturnGoodsAgentSaveVO saveVO) {
        // 校验
        getSysUser(httpRequest);
        // 创建
        UserLoginCacheDTO user = new UserLoginCacheDTO();
        user.setMemberId(saveVO.getMemberId());
        user.setMemberRoleId(saveVO.getMemberRoleId());
        user.setCompany(saveVO.getCompany());
        return user;
    }

    /**
     * 售后退货申请-待提交退货申请单-提交退货申请单-设置需要退货
     * @author 伍将
     * @date 2020/9/25
     **/
    @RequestMapping("/setNeedReturnGoods")
    public Wrapper<Void> setNeedReturnGoods(HttpServletRequest httpRequest, @RequestBody @Valid ReturnGoodsDetailSetStatusVO setStatusVO) {
        return returnedGoodsService.setNeedReturnGoods(getSysUser(httpRequest), setStatusVO);
    }

    /**
     * 售后退货申请-待提交退货申请单-删除退货申请
     * @author 伍将
     * @date 2020/9/10
     **/
    @RequestMapping("/delete")
    public Wrapper<Void> delete(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.delete(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货申请-待提交退货申请单-提交退货申请单-提交
     * @author 伍将
     * @date 2020/9/10
     **/
    @RequestMapping("/submit")
    public Wrapper<Void> submit(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.submit(getSysUser(httpRequest), commonIdVO.getDataId());
    }


    /**
     * 售后退货处理-退货申请单查询-分页查询退货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageBySupplier", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageBySupplier(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageBySupplier(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货处理-查询退货申请详情
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/getDetailBySupplier", method = RequestMethod.GET)
    public Wrapper<ReturnGoodsDetailVO> getDetailBySupplier(HttpServletRequest httpRequest, Long returnId) {
        return returnService.getDetailBySupplier(getSysUser(httpRequest), returnId);
    }

    /**
     * 售后退货处理-待提交退货申请单-分页查询退货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageToBeSubmitBySupplier", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeSubmitBySupplier(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeSubmitBySupplier(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货处理-待提交审核退货申请单-提交审核退货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping("/submitVerify")
    public Wrapper<Void> submitVerify(HttpServletRequest httpRequest, @RequestBody @Valid ReturnSubmitVerifyVO verifyVO) {
        return returnService.submitVerify(getSysUser(httpRequest), verifyVO);
    }

    /**
     * 售后退货处理-待审核退货申请单(一级)-分页查询退货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageToBeVerifyStepOne", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeVerifyStepOne(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeVerifyStepOne(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货处理-待审核退货申请单(一级)-审核退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/verifyStepOne")
    public Wrapper<Void> verifyStepOne(HttpServletRequest httpRequest, @RequestBody @Valid VerifyVO verifyVO) {
        return returnService.verifyStepOne(getSysUser(httpRequest), verifyVO);
    }

    /**
     * 售后退货处理-待审核退货申请单(二级)-分页查询退货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageToBeVerifyStepTwo", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeVerifyStepTwo(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeVerifyStepTwo(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货处理-待审核退货申请单(二级)-审核退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/verifyStepTwo")
    public Wrapper<Void> verifyStepTwo(HttpServletRequest httpRequest, @RequestBody @Valid VerifyVO verifyVO) {
        return returnService.verifyStepTwo(getSysUser(httpRequest), verifyVO);
    }

    /**
     * 售后退货处理-待确认退货申请单-分页查询退货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageToBeConfirmVerify", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeConfirmVerify(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeConfirmVerify(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货处理-待确认退货申请单-确认审核退货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping("/confirmVerify")
    public Wrapper<Void> confirmVerify(HttpServletRequest httpRequest, @RequestBody @Valid VerifyVO verifyVO) {
        return returnService.confirmVerify(getSysUser(httpRequest), verifyVO);
    }

    /**
     * 售后退货申请-待新增退货发货单-新增退货发货单
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/addReturnDeliveryGoods")
    public Wrapper<Long> addReturnDeliveryGoods(HttpServletRequest httpRequest,@RequestBody @Valid ReturnDeliveryGoodsAddVO addVO) {
        return returnService.addReturnDeliveryGoods(getSysUser(httpRequest),addVO);
    }

    /**
     * 售后退货申请-待新增退货发货单-分页查询退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping(value = "/pageToBeAddReturnDeliveryGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeAddReturnDeliveryGoods(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeAddReturnDeliveryGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     *  售后退货申请-待新增退货发货单-详情
     * @date 2021/8/13
     * @version 2.0.0
     */
    @RequestMapping(value = "/getReturnDeliveryGoodsDetail", method = RequestMethod.GET)
    public Wrapper<ReturnGoodsBatchDetailVO> getReturnDeliveryGoodsDetail(HttpServletRequest httpRequest,Long returnDeliveryId) {
        return returnService.getReturnGoodsDeliveryOrReceiveDetail(getSysUser(httpRequest), returnDeliveryId,false);
    }

    /**
     * 售后退货申请-待新增退货发货单-审核退货发货
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/verifyReturnDeliveryGoods")
    public Wrapper<Void> verifyReturnDeliveryGoods(HttpServletRequest httpRequest, @RequestBody CommonIdVO commonIdVO) {
        return returnService.verifyReturnDeliveryGoodsByConsumer(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货申请-待新增物流单-分页查询退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping(value = "/pageToBeAddLogisticsByConsumer", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeAddLogisticsByConsumer(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeAddLogisticsByConsumer(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货申请-待退货发货单-分页查询退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping(value = "/pageToBeReturnDeliveryGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeReturnDeliveryGoods(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeReturnDeliveryGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货申请-待退货发货单-确认退货发货
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/confirmReturnDeliveryGoods")
    public Wrapper<Void> confirmReturnDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.confirmReturnDeliveryGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货申请-待退货发货单-手工退货发货[废弃,调用manualReturnDeliveryGoodsCommon]
     * @param httpRequest 请求
     * @param deliveryGoodsVO 交货货物
     * @return 手工退货发货
     */
    //@RequestMapping("/manualReturnDeliveryGoods")
    public Wrapper<Void> manualReturnDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid ManualDeliveryGoodsVO deliveryGoodsVO) {
        return returnService.manualReturnDeliveryGoods(getSysUser(httpRequest), deliveryGoodsVO);
    }

    /**
     * 售后退货申请-待退货发货单-手工退货发货
     * @param httpRequest  请求
     * @param returnManualGoodsVO 手工退货数据
     * @return 拖货结果
     */
    @RequestMapping("/manualReturnDeliveryGoods")
    public Wrapper<Void> manualReturnDeliveryGoodsCommon(HttpServletRequest httpRequest, @RequestBody @Valid ReturnManualGoodsVO returnManualGoodsVO) {
        return returnService.manualReturnDeliveryGoodsCommon(getSysUser(httpRequest), returnManualGoodsVO);
    }

    /**
     * 售后退货处理-待新增退货收货单-分页查询退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping(value = "/pageToBeAddReturnGoodsStorage", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeAddReturnGoodsStorage(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeAddReturnGoodsStorage(getSysUser(httpRequest), pageVO);
    }

    /**
     *  售后退货处理-待新增退货收货单-详情
     * @date 2021/8/13
     * @version 2.0.0
     */
    @RequestMapping(value = "/getReturnGoodsStorageDetail", method = RequestMethod.GET)
    public Wrapper<ReturnGoodsBatchDetailVO> getReturnGoodsStorageDetail(HttpServletRequest httpRequest,Long returnDeliveryId) {
        return returnService.getReturnGoodsDeliveryOrReceiveDetail(getSysUser(httpRequest), returnDeliveryId,true);
    }

    /**
     *  售后退货处理-待新增退货收货单-新增退货收货单
     * @author ds
     * @date 2021/8/13
     * @version 2.0.0
     */
    @RequestMapping("/addReturnGoodsStorage")
    public Wrapper<Void> addReturnGoodsStorage(HttpServletRequest httpRequest,@RequestBody @Valid ReturnReceiveAddVO addVO) {
        return returnService.addReturnGoodsStorage(getSysUser(httpRequest),addVO);
    }

    /**
     * 售后退货处理-待新增退货收货单-审核退货收货单
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/verifyReturnGoodsStorage")
    public Wrapper<Void> verifyReturnGoodsStorage(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.verifyReturnGoodsStorageBySupplier(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货处理-待退货收货-分页查询退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping(value = "/pageToBeReturnReceiveGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeReturnReceiveGoods(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeReturnReceiveGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货处理-待退货收货-确认退货收货[废弃,统一调用confirmManualReturnReceiveGoodsCommon]
     * @author 伍将
     * @date 2020/9/24
     **/
    //@RequestMapping("/confirmReturnReceiveGoods")
    public Wrapper<Void> confirmReturnReceiveGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.confirmReturnReceiveGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货处理-待退货收货-确认手工退货收货[废弃,统一调用confirmManualReturnReceiveGoodsCommon]
     * @author 伍将
     * @date 2020/12/5
     **/
    //@RequestMapping("/confirmManualReturnReceiveGoods")
    public Wrapper<Void> confirmManualReturnReceiveGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.confirmManualReturnReceiveGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货处理-待退货收货-确认退货收货
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/confirmReturnReceiveGoods")
    public Wrapper<Void> confirmManualReturnReceiveGoodsCommon(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.confirmManualReturnReceiveGoodsCommon(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货申请-待确认退货回单-分页查询退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping(value = "/pageToBeConfirmReturnGoodsReceipt", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeConfirmReturnGoodsReceipt(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeConfirmReturnGoodsReceipt(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货申请-待确认退货回单-确认退货回单
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/confirmReturnGoodsReceipt")
    public Wrapper<Void> confirmReturnGoodsReceipt(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.confirmReturnGoodsReceipt(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货申请-待确认退货回单-继续退货发货[废弃：通过确认回单就行状态流转]
     * @param httpRequest 请求
     * @param commonIdVO id
     * @return 退货结果
     */
    //@RequestMapping("/continueReturnDeliveryGoods")
    public Wrapper<Void> continueReturnDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.continueReturnDeliveryGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货申请-待确认退货回单-确认全部退货回单[废弃：通过确认回单就行状态流转]
     * @author 伍将
     * @date 2020/9/24
     **/
    //@RequestMapping("/confirmAllReturnGoodsReceipt")
    public Wrapper<Void> confirmAllReturnGoodsReceipt(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.confirmAllReturnGoodsReceipt(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货处理-待退款-分页查询退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping(value = "/pageToBeRefund", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeRefund(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeRefund(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货处理-待退款-退款
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/refund")
    public Wrapper<Void> refund(HttpServletRequest httpRequest, @RequestBody @Valid RefundVO refundVO) {
        return returnService.refund(getSysUser(httpRequest), refundVO);
    }

    /**
     * 售后退货处理-待退款-完成所有退款
     * @author 伍将
     * @date 2020/12/9
     **/
    @RequestMapping("/completeRefund")
    public Wrapper<Void> completeRefund(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.completeRefund(getSysUser(httpRequest), commonIdVO);
    }


    /**
     * 售后退货申请-待确认退款-分页查询退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping(value = "/pageToBeConfirmRefund", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeConfirmRefund(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeConfirmRefund(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货申请-待确认退款-确认退款
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/confirmRefund")
    public Wrapper<Void> confirmRefund(HttpServletRequest httpRequest, @RequestBody @Valid ReturnGoodsConfirmRefundVO confirmRefundVO) {
        return returnService.confirmRefund(getSysUser(httpRequest), confirmRefundVO);
    }

    /**
     * 售后退货申请-待确认退款-确认全部退款
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/confirmAllRefund")
    public Wrapper<Void> confirmAllRefund(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return returnService.confirmAllRefund(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货申请-待确认售后完成-分页查询退货申请
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping(value = "/pageToBeComplete", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeComplete(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeComplete(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货申请-待确认售后完成-确认售后完成
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/confirmComplete")
    public Wrapper<Void> confirmComplete(HttpServletRequest httpRequest, @RequestBody @Valid ReturnConfirmCompleteVO completeVO) {
        return returnService.confirmComplete(getSysUser(httpRequest), completeVO);
    }

    /**
     * 分页查询列表页面搜索条件内容
     * @author 伍将
     * @date 2020/10/17
     **/
    @RequestMapping(value = "/pageItems", method = RequestMethod.GET)
    public Wrapper<ReturnGoodsPageItemsVO> pageItems(HttpServletRequest httpRequest) {
        return returnService.pageItems(getSysUser(httpRequest));
    }

    /**
     * 分页查询内部流转记录
     * @author 伍将
     * @date 2020/10/19
     **/
    @RequestMapping(value = "/pageInnerWorkflowRecord", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnInnerWorkflowRecordVO>> pageInnerWorkflowRecord(HttpServletRequest httpRequest, @Valid WorkflowPageVO pageVO) {
        return innerWorkflowRecordService.pageReturnRecord(getSysUser(httpRequest), pageVO);
    }

    /**
     * 分页查询外部流转记录
     * @author 伍将
     * @date 2020/10/19
     **/
    @RequestMapping(value = "/pageOuterWorkflowRecord", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnOuterWorkflowRecordVO>> pageOuterWorkflowRecord(HttpServletRequest httpRequest, @Valid WorkflowPageVO pageVO) {
        return outerWorkflowRecordService.pageReturnRecord(getSysUser(httpRequest), pageVO);
    }

    /**
     * 采购商获取退货发货统计
     * @author 伍将
     * @date 2020/10/19
     **/
    @RequestMapping(value = "/pageStatisticsByConsumer", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsStatisticsVO>> pageStatisticsByConsumer(@Valid ReturnGoodsDetailPageVO pageVO) {
        return returnedGoodsService.pageStatisticsByConsumer(pageVO);
    }

    /**
     * 供应商商获取退货发货统计
     * @author 伍将
     * @date 2020/10/19
     **/
    @RequestMapping(value = "/pageStatisticsBySupplier", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsStatisticsVO>> pageStatisticsBySupplier(@Valid ReturnGoodsDetailPageVO pageVO) {
        return returnedGoodsService.pageStatisticsBySupplier(pageVO);
    }

    /**
     * 采购商分页获取退款
     * @param pageVO 分页查询条件
     * @return 分页获取退款
     */
    @RequestMapping(value = "/pageRefundByConsumer", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsRefundVO>> pageRefundByConsumer(@Valid ReturnGoodsDetailPageVO pageVO) {
        return returnedGoodsService.pageRefundByConsumer(pageVO);
    }

    /**
     * 供应商分页获取退款
     * @param pageVO 分页查询条件
     * @return 供应商分页获取退款
     */
    @RequestMapping(value = "/pageRefundBySupplier", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsRefundVO>> pageRefundBySupplier(@Valid ReturnGoodsDetailPageVO pageVO) {
        return returnedGoodsService.pageRefundBySupplier(pageVO);
    }

    /**
     * 分页查询发货
     * @author 伍将
     * @date 2020/10/19
     **/
    @RequestMapping(value = "/pageDeliveryGoods", method = RequestMethod.GET)
    public Wrapper<PageData<DeliveryGoodsVO>> pageDeliveryGoods(HttpServletRequest httpRequest, @Valid DeliveryGoodsPageVO pageVO) {
        return returnDeliveryGoodsService.pageDeliveryGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     * 分页查询收货
     * @author 伍将
     * @date 2020/10/19
     **/
    @RequestMapping(value = "/pageReceiveGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReceiveGoodsVO>> pageReceiveGoods(HttpServletRequest httpRequest, @Valid ReceiveGoodsPageVO pageVO) {
        return returnDeliveryGoodsService.pageReceiveGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     * 平台后台-退货申请单管理-分页查询退货申请
     * @author 伍将
     * @date 2020/12/7
     **/
    @RequestMapping(value = "/pageByPlatform", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageByPlatform(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageByPlatform(getSysUser(httpRequest), pageVO);
    }

    /**
     * 平台后台-退货申请单管理-查询退货申请详情
     * @author 伍将
     * @date 2020/12/7
     **/
    @RequestMapping(value = "/getDetailPlatform", method = RequestMethod.GET)
    public Wrapper<ReturnGoodsDetailVO> getDetailPlatform(HttpServletRequest httpRequest, Long returnId) {
        return returnService.getDetailPlatform(getSysUser(httpRequest), returnId);
    }

    /**
     * 平台后台-退货申请单管理-分页获取退款
     * @author 伍将
     * @date 2020/12/7
     **/
    @RequestMapping(value = "/pageRefundByPlatform", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageRefundByPlatform(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageRefundByPlatform(getSysUser(httpRequest), pageVO);
    }

    /**
     * 物流服务-分页获取退货商品
     * @author 伍将
     * @date 2020/12/8
     **/
    @RequestMapping(value = "/pageCommodityByLogistics", method = RequestMethod.GET)
    public Wrapper<PageData<CommodityQueryVO>> pageCommodityByLogistics(@Valid CommodityPageVO pageVO) {
        return returnDeliveryGoodsService.pageCommodityByLogistics(pageVO);
    }

    /**
     * 物流服务-分页获取待新增物流申请单
     * @author 伍将
     * @date 2020/12/8
     **/
    @RequestMapping(value = "/pageByLogistics", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyOrderQueryVO>> pageByLogistics(HttpServletRequest httpRequest, @Valid ApplyOrderPageVO pageVO) {
        return returnService.pageByLogistics(getSysUser(httpRequest), pageVO);
    }

    /**
     * 物流服务-获取退货申请单详情
     * @author 伍将
     * @date 2020/12/9
     **/
    @RequestMapping(value = "/pageDetailByLogistics", method = RequestMethod.GET)
    public Wrapper<ApplyOrderQueryVO> pageDetailByLogistics(Long returnId) {
        return returnService.pageDetailByLogistics(returnId);
    }

    /**
     * 仓库服务-分页查询待新增退货发货单
     * @author 伍将
     * @date 2020/12/22
     **/
    @RequestMapping(value = "/pageToBeAddReturnDeliveryByWarehouse", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeAddReturnDeliveryByWarehouse(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeAddReturnDeliveryByWarehouse(getSysUser(httpRequest), pageVO);
    }

    /**
     * 仓库服务-分页查询待新增退货入库单
     * @author 伍将
     * @date 2020/12/22
     **/
    @RequestMapping(value = "/pageToBeAddReturnStorageByWarehouse", method = RequestMethod.GET)
    public Wrapper<PageData<ReturnGoodsQueryVO>> pageToBeAddReturnStorageByWarehouse(HttpServletRequest httpRequest, @Valid ReturnGoodsPageVO pageVO) {
        return returnService.pageToBeAddReturnStorageByWarehouse(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后退货处理-退货申请单查询-中止售后
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/stopReturnGoods")
    public Wrapper<Void> stopReturnGoods(HttpServletRequest httpRequest, @RequestBody @Valid ReturnGoodsStopVO stopVO) {
        return returnService.stopReturnGoods(getSysUser(httpRequest), stopVO);
    }
}
